package com.dyh.quickdemo.dasync;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/*
@Author=Joey Wheeler
@Date=2021/3/11 17:21
*/
@Service
public class AsyncHandlerCoreService {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    AsyncHandlerCenter asyncHandlerCenter;

    public void run(AsyncEventContext asyncEventContext) {
        logger.info(JSON.toJSONString(asyncEventContext));

        asyncHandlerCenter.get(asyncEventContext.getType()).accept(asyncEventContext.getData());
    }
}
